<script type="text/javascript">
	$(function(){
		icon($('select[name=layout_id] option:selected').val());
		$('select[name=layout_id]').change(function(){
			icon($(this).val());
		})
	})
	
function icon(value)
{
	if(value==6){
		$('.image-menu2').show();
	}else{
		$('.image-menu2').hide();
	}
}
</script>
<h1 style="margin:0 0 15px;">หมวดหมู่ <?php echo (isset($parent))? '» '.admin_breadcrumb(get_breadcrumb($parent->id,TRUE)):'' ?></h1>
<form method="post" action="contents/admin/categories/save/<?php echo $category->id?>" enctype="multipart/form-data">
	<table class="form">
		<tr>
			<th>ชื่อหมวดหมู่</th>
			<td>
				<input type="text" name="name" value="<?php echo $category->name?>" />
			</td>
		</tr>
		
		<?php if(isset($parent->id)): ?>
		<tr>
			<th>Layout</th>
			<td>
				<?php $layout = new layout; echo $layout->option(1, $category->layout_id); ?>
			</td>
		</tr>
		<?php endif; ?>
		<tr>
			<th>รูปแบบ</th>
			<td>
				<?php echo form_dropdown('structure_id', $structure->get()->all_to_assoc('id', 'description'),$category->structure_id) ?>
			</td>
		</tr>
		<?php if(!isset($parent->id)): ?>
		<tr>
			<th>Slug</th>
			<td>
				<input type="text" name="slug" value="<?php echo $category->slug?>" />
			</td>
		</tr>
		<?php endif; ?>
		<tr class="image-menu2" style="display:none;">
			<th>สัญญาลักษณ์เมนู</th>
			<td><?php echo form_icon('menu', 'menu2', $category->menu); ?></td>
		</tr>
		<tr class="image-head">
			<th>สัญญาลักษณ์</th>
			<td><?php echo form_icon('image', 'head', $category->image); ?></td>
		</tr>
		<tr>
			<th>สี</th>
			<td><?php echo form_color('color', $category->color); ?></td>
		</tr>
		<tr>	
			<th></th>
			<td>
				<?php if((isset($parent))): ?>
				<?php echo form_hidden('parent_id',$parent->id)?>
				<?php endif; ?>
				<?php echo form_submit('',lang('btn_submit'),'class="button"')?>
				<?php echo form_button('',lang('btn_back'),'class="button" onclick="window.location = \'contents/admin/categories\'"')?>
			</td>
		</tr>
	</table>
</form>